package cn.deschen.search.index.adCreative;

import cn.deschen.common.config.cache.Cache;
import cn.deschen.search.index.IndexAware;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * @Author hanbin_chen
 * @Description 创意广告索引，二级索引
 * @DateTime 2021/6/5
 * @Version V1.0.0
 */
@Component
@EqualsAndHashCode
public class AdCreativeIndex extends IndexAware<Long, AdCreativeObject> {

    public static final String INDEX_TYPE = "CREATIVE";

    @Autowired
    public AdCreativeIndex(Cache<String, AdCreativeObject> cache) {
        super(cache, INDEX_TYPE);
    }

    public List<AdCreativeObject> matchCreative(Set<Long> creativeIdList) {
        return creativeIdList.stream().map(creativeId -> get(creativeId)).collect(Collectors.toList());
    }
}
